//统一管理相关的接口
import request from "@/utils/request";
import type { Preference } from "./type" 

//统一管理接口
enum API {
    //偏好组合URL
    PREFERENCE_URL = "/itp/api/pref/combination",
     //偏好带value
    Dict_URL = "/itp/api/dict",
    Dept_URL = "/itp/api/dept",
    riskColumn_URL = "/itp/risk/common/column",
    Index_URL = "/itp/index/management",
    IndexParam_URL = "/itp/index/param",
    riskSource_URL = "/itp/risk/common/column-source",
    accPosition_URL = "/itp/api/select/account/position",
    apiParam_URL = "/itp/api/param",
    dacSource_URL = "/itp/data/perm/source",
    reportCall_url = "/itp/api/report/call",
    common_url = "/itp/data/perm/common",
}
//暴露请求函数
//获取字典
export const getDictionary = (code: string) => request.get(`${API.Dict_URL}/code?code=${code}`);
//保存偏好
export const savePreference = (form: Preference[]) => request.post(`${API.PREFERENCE_URL}/save/update/all/with/detail`,form);
//删除偏好
export const delPreference = (form: {code: string; forUserId: number; forPrefInfoId: number;}) => request.put(`${API.PREFERENCE_URL}/delete/all/with/detail`,form);
//获取偏好
export const getPreference = (form:{code: string,forPrefInfoId: number,isDefault:number}) => request.post(`${API.PREFERENCE_URL}/all/with/detail`,form);

export default {
    getDictList: (current: number, size: number, data: any) => request.post(`${API.Dict_URL}/page?current=${current}&size=${size}`, data),
    getDictDetail: (id: number) => request.get(`${API.Dict_URL}/id?id=${id}`),
    dictDelete: (id: number) => request.delete(`${API.Dict_URL}?id=${id}`),
    dictAdd: (param: any) => request.post(`${API.Dict_URL}`,param),
    dictUpdate: (param: any) => request.put(`${API.Dict_URL}`,param),
    getDictClassCodesList: (current: number, size: number ) => request.get(`${API.Dict_URL}/page/classCodes?current=${current}&size=${size}`),
    getDictByClassCodes:(classCodes: string[]) => request.post(`${API.Dict_URL}/classCodes`,classCodes),
    // 字典分类下拉框
    dictSelect: (param: string, current: number, size: number) => request.get(`${API.Dict_URL}/page/classCodes?searchKey=${param}&current=${current}&size=${size}`),

    getDeptList: ( param: any) => request.post(`${API.Dept_URL}/all`, param),
    getDeptDetail: (id: number) => request.get(`${API.Dept_URL}/id?id=${id}`),
    deptDelete: (id: number) => request.delete(`${API.Dept_URL}?id=${id}`),
    deptAdd: (param: any) => request.post(`${API.Dept_URL}`,param),
    deptUpdate: (param: any) => request.put(`${API.Dept_URL}`,param),
    // 获取省份信息
    getProvince: (param: any) => request.get(`basic-service/api/province/getList?${param}`),
    // isWhiteColumn 是否白名单，1-是，0-否
    riskColumnSelect: (param: any) => request.post(`${API.riskColumn_URL}/select`,param), 
    // 指标管理下拉框
    indexSelect:(param:any)=>request.post(`${API.Index_URL}/select`,param),
    // 指标管理参数下拉框
    indexParamSelect: (param: any) => request.post(`${API.IndexParam_URL}/select`,param),
    // 字段+资源的值下拉框
    riskSourceSelect: (param: any) => request.post(`${API.riskSource_URL}/select`,param),
    // 持仓账户下拉框
    accPositionSelect: (param: any) => request.post(`${API.accPosition_URL}`,param),
    // 查询O32流水证券类别
    stockTypeSelect: () => request.get(`${API.Dict_URL}/find/stockType`),
    // 参数定义下拉框
    paramDefSelect: (current: number, size: number, param: any) => request.post(`${API.apiParam_URL}/def/page?current=${current}&size=${size}`,param),
    // 资源下拉框
    dacSourceSelect: (page: number, size: number, param: any) => request.post(`${API.dacSource_URL}/page?page=${page}&size=${size}`,param),
    // 通用报表
    reportGeneral: (param: any) => request.post(`${API.reportCall_url}`,param),
    exportReportGeneral: (param: any) => request.exportFile(`${API.reportCall_url}/export`,param),
    // 内置参数
    commonInsideParam: (param: any) => request.get(`${API.common_url}/inside/param?${param}`),
    // 资源视图下拉框
    selectDataSourceView: (param: any) => request.get(`${API.dacSource_URL}/view/select?searchKey=${param}`),
    // 资源报表下拉框 
    selectDataSourceReport: (param: any) => request.get(`${API.dacSource_URL}/report/select?searchKey=${param}`),
}
